
********************************************************************************************************************************
						
														***Marlene Mauk, Max Groemping***
			***Online Disinformation Predicts Inaccurate Beliefs about Election Fairness among Winners and Losers***
											***Replication File  ##4 - VALIDATION AND DESCRIPTIVES 1***
						
********************************************************************************************************************************


** validation of electoral integrity measure
*difference in standard deviations between expert evaluations and public perceptions of electoral integrity (Figure C1)
use mergeddata.dta
sum pef01
logout, save(pefstdv) dta replace: tabstat pef01, by(eleid) statistics(sd)
keep (eleid election)
collapse (firstnm) election, by(eleid)
save lookup.dta, replace
clear
use pefstdv.dta
rename v1 eleid 
rename v2 pefstdv
drop v3 v4
destring eleid pefstdv, force replace
drop if eleid==.
save pefstdv.dta, replace
clear
use pei_exp_factors_exp.dta, clear
sum pei_w
gen pei_w_exp01 = ((pei_w-r(min))/(r(max)-r(min)))
logout, save(peistdv) dta replace: tabstat pei_w_exp01, by(eleid) statistics(sd)
use peistdv.dta
rename v1 eleid 
rename v2 peistdv
drop v3 v4
destring eleid peistdv, force replace
drop if eleid==.
merge 1:1 eleid using pefstdv
drop _merge
merge 1:1 eleid using lookup
drop _merge
gen dif = pefstdv-peistdv
sort dif
gen order=-_n
labmask order, values(election)
twoway dropline dif order, horizontal msize(tiny) graphregion(color(white)) lwidth(vthin) lcolor(black) mcolor(black) xtitle("STDEV(Public) - STDEV(Expert)", size(vsmall)) ytitle("Election", size(vsmall)) xlabel(, labsize(vsmall) labcolor(gs6) tlwidt(vthin)) ylabel(-1(1)-82, valuelabel labsize(tiny) angle(horizontal) nogrid labcolor(gs6) tlwidth(vthin)) 
graph display, ysize(8)
graph export .\figures\figurec1.png, replace
clear


** validation of electoral integrity measure
*pairwise correlations pei01 and alternative measures of electoral integrity (Table C2)
use mergeddata.dta
collapse pei01 pei_exp01 nelda11 v2xel_frefair, by(elecow)
pwcorr pei01 pei_exp01 nelda11 v2xel_frefair, sig obs
clear


** validation of disinformation measure
*pairwise correlations disinfo01 with alternative measures of disinformation (Table D2)
use mergeddata.dta
collapse disinfo01 newsinaccurate newsfake v2smgovdom v2smfordom v2smpardom, by(elecow)
pwcorr disinfo01 v2smgovdom v2smfordom v2smpardom newsfake newsinaccurate, sig obs
clear

*internet penetration rates (Figure D1)
use mergeddata.dta
collapse internet eleyear cowcode, by(elecow)
lab val cowcode cowcode
scatter internet eleyear, graphregion(color(white)) xtitle(" ") ytitle("internet penetration rate (percent)") mstyle(p5) msize(medium) msymbol(plus) xscale(range(2011.5 2018.5)) xlabel(2012 2013 2014 2015 2016 2017 2018) yscale(range(0 100)) ylabel(0 20 40 60 80 100, format(%9.1gc)) ///
|| scatter internet eleyear if internet<=30, mstyle(p5) msize(medium) msymbol(plus) mlabel(cowcode) mlabposition(6) mlabcolor(gs10) mlabsize(vsmall) legend(off)
graph export .\figures\figured1.png, replace 
clear